import { CellRenderer } from "../../../../fl/controls/listClasses/CellRenderer";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { FriendStyle } from "./FriendStyle";
import { PlayerMiniInfo } from "../../model/PlayerMiniInfo";
import { PlayerOpRegister } from "../common/menu/PlayerOpRegister";
import { PlayerOpMenuConst } from "../common/menu/PlayerOpMenuConst";
import { AvatarInfo } from "../../resource/info/AvatarInfo";
import { AvatarType } from "../../resource/info/AvatarType";
import { ImageInfo } from "../../../../com/gengine/resource/info/ImageInfo";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class FriendRecentTalkCellRender
    
    export  class FriendRecentTalkCellRender extends CellRenderer
    {
        constructor()
        {
            super();
            this.width = 180;
            this.initStyles();
            this.create();
            return;
        }

        /* internal  */initStyles(): void
        {
            this.setStyle("downSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("overSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedOverSkin", GlobalClass.getBitmap("Friend_over"));
            this.setStyle("selectedUpSkin", GlobalClass.getBitmap("Friend_over"));
            return;
        }

        /* internal  */create(): void
        {
            this._headImage = new Object /* flash.display.Bitmap */();
            this._headImage.width = 20;
            this._headImage.height = 20;
            this._headImage.y = 1;
            this.addChild(this._headImage);
            this._textName = new Object /* flash.text.TextField */();
            this._textName.x = 25;
            this._textName.width = 90;
            this._textName.height = 20;
            this._textName.mouseEnabled = false;
            this._textName.filters = [FilterConst.nameGlowFilter];
            this._textName.defaultTextFormat = FriendStyle.textFormatOnLine;
            this.addChild(this._textName);
            this._textCamp = new Object /* flash.text.TextField */();
            this._textCamp.x = 115;
            this._textCamp.width = 40;
            this._textCamp.height = 20;
            this._textCamp.mouseEnabled = false;
            this._textCamp.filters = [FilterConst.nameGlowFilter];
            this._textCamp.defaultTextFormat = FriendStyle.textFormatOnLine;
            this.addChild(this._textCamp);
            this.configListeners();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._friendInfo = arg1 as PlayerMiniInfo;
            PlayerOpRegister.Register(this, this._friendInfo, PlayerOpMenuConst.RecentListOpMenu);
            this.refresh();
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal  */refresh(arg1: Boolean=false): void
        {
            var isAlwaysGray: Boolean=false;
            var imgName: string;

            var loc1;
            isAlwaysGray = arg1;
            imgName = AvatarInfo.getPlayerAvatarName(this._friendInfo.camp, this._friendInfo.sex, AvatarType.FRIEND, this._friendInfo.avatarId);
            with ({}) 
            {
            };
            imgName.load(
#error('pushwith') {}
            , 
#error('pushwith') {}
            .onAvatarLoaded = (arg1: ImageInfo): void
            {
                _headImage.bitmapData = arg1.bitmapData;
                _headImage.width = 20;
                _headImage.height = 20;
                _headImage.y = 1;
                return;
            })
            this._textName.text = this._friendInfo.playerName;
            this._textCamp.text = this._friendInfo.campName;
            if (this._friendInfo.online && !isAlwaysGray) 
            {
                this._headImage.filters = [];
                var loc2=this._friendInfo.intVIP;
                switch (loc2) 
                {
                    case 9:
                    {
                        this._textName.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textCamp.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textName.filters = [FilterConst.vipGlowFilter];
                        this._textCamp.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    case 6:
                    {
                        this._textName.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textCamp.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textName.filters = [FilterConst.vipGlowFilter];
                        this._textCamp.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    case 3:
                    {
                        this._textName.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textCamp.setTextFormat(GlobalStyle.textFormatVIP3);
                        this._textName.filters = [FilterConst.vipGlowFilter];
                        this._textCamp.filters = [FilterConst.vipGlowFilter];
                        break;
                    }
                    default:
                    {
                        this._textName.setTextFormat(FriendStyle.textFormatOnLine);
                        this._textCamp.setTextFormat(FriendStyle.textFormatOnLine);
                        this._textName.filters = [FilterConst.nameGlowFilter];
                        this._textCamp.filters = [FilterConst.nameGlowFilter];
                    }
                }
            }
            else 
            {
                this._headImage.filters = [FilterConst.colorFilter];
                this._textName.setTextFormat(FriendStyle.textFormatOffline);
                this._textCamp.setTextFormat(FriendStyle.textFormatOffline);
                this._textName.filters = [FilterConst.nameGlowFilter];
                this._textCamp.filters = [FilterConst.nameGlowFilter];
            }
            return;
        }

        /* internal  */configListeners(): void
        {
            this.addEventListener(flash.events.MouseEvent.DOUBLE_CLICK, this.dblClickHandler);
            return;
        }

        /* internal  */dblClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.FriendPrivateChatDBClick, this._friendInfo));
            return;
        }

        /* internal */ /* var */_friendInfo: PlayerMiniInfo;

        /* internal */ /* var */_headImage: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_textName: Object /* flash.text.TextField */;

        /* internal */ /* var */_textCamp: Object /* flash.text.TextField */;
    }
